<template>
    <view :class="themeClass" style="padding-bottom:calc(var(--window-bottom)+160px);">
      <!-- <view  class="bg-151518" style="padding-bottom:calc(var(--window-bottom)+160px);"> -->
		<!-- #ifdef MP-WEIXIN -->
		<v-kefu @tap="tokefu()"></v-kefu>
		<!-- #endif -->
		<!-- #ifndef MP-WEIXIN -->
		<view @click="tokefu()" class="">
		  <v-kefu></v-kefu>
		</view>
		<!-- #endif -->
		<v-popup @update:isShow="isShow = $event" :isShow="isShow"></v-popup>

		<!-- #ifdef MP-WEIXIN -->
		<u-navbar
		:titleStyle="'{color: #ffffff}'"
		title="寄售中心" 
		bgColor="#1D1D29"
		@leftClick="backHome"
		:placeholder="true"
		leftIconColor="#FFFFFF"></u-navbar>
		<!-- #endif -->
		<u-gap height="28rpx"></u-gap>
		<view class="padding-0-20">
			<view :class="themeClass" class="cu-list menu border-radius-16  padding-0-30">
				<view class="flex flex-align-center flex-space-between input-item" @tap="showModal" data-target="kajuan">
					<view class="content">
						<text class="text-grey" :class="themeClass">卡卷</text>
						<text :class="themeClass"  class="margin-left-xl color-EBCC9D">{{kajuan.title}}</text>
					</view>
					<view class="action flex flex-align-center">
						<image :src="kajuan.wapimage" mode="aspectFill"></image>
						<u-icon name="arrow-right" color="#787896"></u-icon>
					</view>
				</view>
				<view class="flex flex-align-center flex-space-between input-item" @tap="showModal" data-target="kazong">
					<view class="content">
						<text class="text-grey" :class="themeClass">卡种</text>
						<text :class="themeClass" class="margin-left-xl color-EBCC9D" v-if="cardid!=0">{{kazong.title}}</text>
						<text :class="themeClass" class="margin-left-xl color-EBCC9D" v-else>请选择卡种</text>
					</view>
					<view class="action  flex flex-align-center">
						<image :src="kazong.img" mode="aspectFit" v-show="cardid!=0"></image>
						<u-icon name="arrow-right" color="#787896"></u-icon>
					</view>
				</view>
				<view class="flex flex-align-center flex-space-between input-item"  @tap="showModal" data-target="mianzhi">
					<view class="content">
						<text class="text-grey" :class="themeClass">面值</text>
						<text :class="themeClass" class="margin-left-xl color-EBCC9D" v-if="moneyid!=null">{{mianzhi.mianzhi}}</text>
						<text :class="themeClass" class="margin-left-xl color-EBCC9D" v-else>请选择面值</text>
					</view>
					
					<view class="action" v-if="kazong.mode==1 && moneyid!=null">
						回收价<text class="text-price text-pink color-E2E2FA">{{parseFloat(mianzhi.feilv).toFixed(2)}}</text>
					</view>
					<view class="flex flex-align-center">
						<view class="action"  v-if="kazong.mode !=1 && moneyid !=null">
							<text class="text-price text-pink color-EBCC9D">{{(parseFloat(mianzhi.mianzhi)*parseFloat(mianzhi.feilv)).toFixed(2)}}</text>
							<!-- <text class="text-orange color-E2E2FA">{{(parseFloat(mianzhi.feilv)*100) .toFixed(2)}}折</text> -->
							<text class="text-orange color-E2E2FA">({{ (parseFloat(mianzhi.feilv) * 100).toFixed(2) }}折)</text>  
						</view>
						<u-icon name="arrow-right" color="#787896"></u-icon>
					</view>
				</view>
        <!-- 折扣一栏 -->
		<!-- 		<view
				v-if="cardItem.isjiaji == 1 && mianzhi.mianzhi"
				class="flex flex-align-center flex-space-between input-item" @tap="showModal" data-target="kazong">
					<view class="content">
						<text class="text-grey">折扣</text>
						<text class="margin-left-xl color-EBCC9D" v-if="mianzhi.feilv!=null">
							{{mianzhi.feilv*100}}%
						</text>
					</view>
				</view> -->
        <!-- 自定义折扣 -->
        <view
        v-if="cardItem.isjiaji == 1 && mianzhi.mianzhi"
        class="flex flex-align-center flex-space-between input-item" data-target="kazong">
        	<view class="content">
        		<view style="display: flex;">
        		  <text style="margin-right: 15rpx;" class="text-grey" >自定义折扣</text>
        		  <input @blur="handlerConfirm" :value="discount" @input="handlerInput"  :placeholder="`请输入费率 ${ cardItem.pricemin*100 }%-${ cardItem.pricemax*100 }%`" style="color: #EBCC9D;" type="text" />
            </view>
        	</view>
        </view>
				<view
				v-if="cardItem.isjiaji == 1 && mianzhi.mianzhi"
				class="color-EBCC9D font26 flex flex-center padding-20-0">
					可以输入的折扣值 {{ cardItem.pricemin*100 }}%-{{ cardItem.pricemax*100 }}%
					数值越高回收越慢
				</view>
			</view>	
			<view
			v-if="cardItem.process"
			 class="padding-20-30  font26 color-B5B5CA margin-t-20 border-radius-8">
				{{ cardItem.process }}
			</view>
			<view :class="themeClass" class="margin-top-sm  border-radius-16 padding-0-30">
				<view >
	
					<view class="nav santou flex" >
						<u-tabs 
						lineHeight="4rpx"
						lineWidth="60rpx"
						lineColor="#F0E5D6"
						:activeStyle="{color: '#F0E5D6'}"
						:list="tabNav" keyName="title" @click="tabnavSelect"></u-tabs>
					</view>
					<block  v-if="TabCur==1">
						<u-gap height="30rpx"></u-gap>
						<view class="" style="padding: 0;overflow-y: hidden;">
							<textarea 
              :class="themeClass"
							:enableNative="false"
							maxlength="-1" 
							style="padding: 20rpx 10rpx;font-size:26rpx" 
							placeholder-class="placeholder-class"
							class="bian radius"  @input="textareaBInput" :value="textareaBValue" :placeholder="kazong.isyzm==0?'输入卡号\卡密 一行一张卡':'输入卡号\卡密\验证码或CVV2码 一行一张卡'" ></textarea>
						</view>
				
						<u-gap height="36rpx"></u-gap>
					</block>
					<block  v-if="TabCur==0">
						<u-gap height="30rpx"></u-gap>
						<view class="">
							<block v-if="iskami==0">
								<view class="input-item-box flex flex-align-center">
									<view class="title color-F0E5D6 font28" :class="themeClass">卡号</view>
									<input 
									:enableNative="false"
									class="flex-1" placeholder-class="placeholder-class" placeholder="请输入礼品卡卡号" data-type="cardno" name="input" v-model="cardno" ></input>
								</view>
								<u-gap height="38rpx"></u-gap>
							</block>
							<block>
								<!-- <input type="number" placeholder="请输入礼品卡卡密" /> -->
								<view class="input-item-box flex flex-align-center">
									<view class="title color-F0E5D6 font28" :class="themeClass">卡密</view>
                  <!-- #ifdef H5 -->
                  <input
                  :enableNative="false"
                  class="flex-1" placeholder-class="placeholder-class" placeholder="请输入礼品卡卡密" data-type="cardkey" name="input" v-model="cardkey"></input>		
               <!-- #endif -->
               <!-- #ifdef APP -->
                 <input
                 :enableNative="false"
                 class="flex-1" placeholder-class="placeholder-class" placeholder="请输入礼品卡卡密" data-type="cardkey" name="input" v-model="cardkey"></input>		
               <!-- #endif -->
									<!-- #ifdef MP-WEIXIN -->
									<input
									class="flex-1" placeholder-class="placeholder-class" placeholder="请输入礼品卡卡密" data-type="cardkey" name="input" v-model="cardkey"></input>
									<!-- #endif -->
								</view>
								<u-gap height="38rpx"></u-gap>
							</block>
							<view v-show="kazong.isyzm0">
								<view class="input-item-box  flex flex-align-center" >
									<view class="title color-F0E5D6 font28">CVV2</view>
									<input class="flex-1" placeholder-class="placeholder-class" placeholder="请输入卡验证码或CVV2码" name="input" @input="getVal"  data-type="cardcode" :value="cardcode"></input>
								</view>
								<u-gap height="38rpx"></u-gap>
							</view>
						</view>
						<u-gap height="20rpx"></u-gap>
					</block>
				</view>
			</view>
			<block  v-if="TabCur==1">
				<u-gap height="36rpx"></u-gap>
				<view class="flex justify-between">
					<view class="btn-arrange flex flex-center color-333 font26" @click="arrange()">整理卡密</view>
					<text class="margin-sm color-BDBDDF" @tap="showModal" data-target="Modal" >卡密示例</text>
				</view>
			</block>
			<view 
			v-if="cardItem.tips"
			class="padding-20-30  font26 color-B5B5CA margin-t-20 border-radius-8">
				{{ cardItem.tips }}
			</view>
			<u-gap height="20rpx"></u-gap>
			<!-- 用户须知 -->
			<view class="rule-box" :class="themeClass">
				<view class="title flex flex-align-center" :class="themeClass">用户须知</view>
				<u-gap height="40rpx"></u-gap>
				<view class="font24 color-C7C7EB" style="line-height: 48rpx;" :class="themeClass">
          <!-- #ifdef MP-WEIXIN -->
          <view  v-html="userNotes">
          </view>
          <!-- #endif -->
       <!-- #ifndef MP-WEIXIN -->
       <view style="height: 700rpx;"  v-html="userNotes">
       </view>
       <!-- #endif -->
		<!-- 			<view>
						1、请正确核对卡号与卡密是否相对应，并保证仅在本平台进行转让，否则可能导致无法结算，给您带来损失。 
					</view>
					<view>
						2、请务必同时输入正确的卡号和卡密，<span class="color: #f0e5d6;">如果卡号错误， 卡密正确也可能给您带来损失。 </span>
					</view>
					<view>
						3、请保证选择的充值卡面值与实际面值一样，面值选错 将无法正常结算，给您带来损失。 
					</view>
					<view>
						4、若上传的卡券已被使用或为错误券码，即便已拿到货 款，后续也会被追责，故请卖家认真核实! 
					</view>
					<view>
						5、为保证您的资金安全，请先进行实名认证再提交，实 名认证通过后方可提现。 
					</view>
					<view>
						6、回收速度可在提交页面选择卡种和面值后，参考输入 框上方显示的最近回收时间和输入框下方的备注。
					</view> -->
				</view>
			</view>
			<!-- #ifdef MP-ALIPAY -->
			<u-gap height="400rpx"></u-gap>
			<!-- #endif -->
		</view>

		<view class="foots flex flex-direction padding-top-xs" :class="themeClass" >
			<view class="margin-xs flex color-BABAF6 font24" >
				<u-checkbox-group @change="RadioChange" style="display: inline-block;">
					<u-checkbox activeColor="#ECB676" :class="radio=='A'?'checked':''" :checked="radio=='A'?true:false" value="A" name="A"></u-checkbox>
				</u-checkbox-group>
				<text :class="themeClass" class="text-sm" style="margin-left: 3px;">我已阅读并同意《<text class="color-F8DB9D" @click="gourl(18)">{{app.title}}服务协议</text>》和《<text class="color-F8DB9D" @click="gourl(19)">{{app.title}}隐私政策</text>》</text>
			</view>
			<button class="cu-btn bg-red margin-sm lg shadow bg-gradual-purple" style="margin-top: 6px;" @tap="subcard">提交卡密</button>
		</view>

		<view class="cu-modal" @tap="hideModal" :class="modalName=='Modal'?'show':''">
			<view class="cu-dialog" @tap.stop="">
				<view class="padding-xl">
					<view class="text-orange">
						卡号与卡密之间请用
					<text class="text-bold">"空格"</text>
					隔开
					</view>
					<view class="text-orange">每张卡占用一行用
					<text class="text-bold">"换行"</text>
					隔开
					</view>
					<view class="">
						例:
					</view>
					<view class="">
						{{lizi}}
					</view>
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn bg-green margin-left" @tap="hideModal">关闭</button>
					</view>
				</view>
			</view>
		</view>
		<!--kajuan-->
		<view class="cu-modal bottom-modal" @tap="hideModal" :class="modalName=='kajuan'?'show':''">
			<view class="cu-dialog" @tap.stop="">
				<view class="text-bold text-lg text-center margin-bottom-sm margin-tb-sm">请选择卡类</view>
				<view class="grid col-3 bg-gray padding-xs">
					<view class="padding-xs text-center" v-for="(ite,ise) in navlis" :key="ise" @tap="sectype" :data-id="ise">
						<view class="padding-top-sm radius shadow-blur">
							<image :src="ite.image" mode="scaleToFill" style="height: 130rpx;"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--end-->
		
		<!--kazong-->
		<view class="cu-modal bottom-modal" @tap="hideModal" :class="modalName=='kazong'?'show':''">
			<view class="cu-dialog" @tap.stop="">
				<view class="text-bold text-lg text-center margin-bottom-sm margin-tb-sm">请选择卡种</view>
				<view class="grid col-2 bg-gray padding-xs" style="max-height: 550rpx;overflow-y: auto;" >
					<view class="text-center  padding-xs " :class="{weihu:item.status==0}" v-for="(item,index) in cardlist" :key="index" @tap="secka" :data-item="item" :data-id="item.id" :data-sid="index">
            <view style="position: relative;"  class="padding-top-sm radius shadow-blur bg-white" :class="{cardid:item.id?'curs':''}">
							<image :src="item.img" mode="aspectFit" style="height: 60rpx;width: 100%;margin-bottom: 2px;"></image>
							<view class="padding-bottom-sm">
								<text>{{item.title}}</text>
							</view>
							<view class="jiao" v-show="cardid==item.id"></view>
              <view style="position: absolute;left: 0;top: 0;color: #fff; height: 50rpx;background-color: #999;text-align: center;line-height: 50rpx;border-radius: 0 0 10rpx 0" class="tip" v-if="item.status==0">维护</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!--end-->
		
		<!--kazong-->
		<view class="cu-modal" @tap="hideModal" :class="modalName=='automoney'?'show':''">
			<view class="cu-dialog" style="width: 60%;" @tap.stop="">
				<view class="text-bold text-lg text-center margin-bottom-sm padding-sm solid-bottom">请输入自定义面值</view>
				<view class="">
					<view class="btnsy">
						<input type="text" v-model="autom" placeholder="请输入10-10000元的面值">
					</view>
					<view class="padding flex flex-direction">
						<button class="cu-btn bg-blue margin-tb-sm lg round" style="width: 90%;margin: auto;" @tap="automoney">确定</button>
					</view>
				</view>
			</view>
		</view>
		<!--end-->
		
		<view class="cu-modal"  @tap="hideModal" :class="modalName=='success'?'show':''">
			<view class="cu-dialog" @tap.stop="">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提交成功</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					{{successtips}}
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="action">
						<button class="cu-btn line-green text-green" @tap="hideModal">继续提交</button>
						<button class="cu-btn bg-green margin-left" @click="goorder('../order/order')">去订单中心</button>
		
					</view>
				</view>
			</view>
		</view>
		
		<view class="cu-modal"  @tap="hideModal" :class="modalName=='errtips'?'show':''">
			<view class="cu-dialog" @tap.stop="">
				<view class="cu-bar bg-white justify-end">
					<view class="content">以下卡有错误</view>
				</view>
				<view class="padding-sm" style="max-height: 550rpx;overflow-y: auto;">
					<view class="margin-xs" v-for="(ites,ins) in errstr">
						<text>{{ites.card}}</text>
						<text class="text-orange margin-left-sm">{{ites.msg}}</text>
					</view>
				</view>
				<view class="text-red bg-white margin-xs padding-xs radius" style="border: #F0AD4E 1px dashed">
				 <view class="">
				 	{{errtips}}
				 </view>	
				 <view class="text-sm text-gray text-left padding-xs">
				 	可以选择部分提交按钮把正确的卡号卡密先提交再修改剩下的错误卡密
				 </view>
				</view>
				<view class="cu-bar bg-white justify-end">
					<view class="margin-right-sm">
						<button class="cu-btn line-orange text-orange" @tap="copyErrStr">复制错误卡号</button>
					</view>
					<view class="action">
						<button class="cu-btn line-green text-green" @tap="hideModal">返回修改</button>
						<button class="cu-btn bg-green margin-left" @tap="gosub" :disabled="isnumok>0">部分提交</button>
					</view>
				</view>
			</view>
		</view>
		
		
		<view class="cu-modal bottom-modal" @tap="hideModal" :class="modalName=='mianzhi'?'show':''">
			<view class="cu-dialog" @tap.stop="">
				<view class="text-bold text-lg text-center margin-bottom-sm margin-tb-sm">请选择面值</view>
				<view class="grid col-3 bg-gray padding-xs" style="max-height: 550rpx;overflow-y: auto;" >
					<view class="padding-xs text-center" v-for="(it,is) in kazong.mianzhi" :key="is" @tap="secmoney" :data-id="is">
						<view class="padding-top-sm radius padding-bottom-sm shadow-blur bg-white" :class="moneyid==is?'curs':''" v-if="it.type==0">
							<view class="bg-white">
								<text class="text-bold">{{it.mianzhi}}</text>
							</view>
							<view class="text-center margin-top-xs text-xs padding-xs" v-if="kazong.mode==0">
             
							    <text class="text-price">{{(parseFloat(it.mianzhi)*parseFloat(it.feilv)).toFixed(2)}}</text>
								<text class="text-orange margin-left-sm">{{parseFloat(it.feilv*100).toFixed(2)}}折</text>
							</view>
							<view class="text-center margin-top-xs text-xs padding-xs" v-else>
							    回收价<text class="text-price text-orange color-E2E2FA">{{parseFloat(it.feilv).toFixed(2)}}</text>
							</view>
							<view class="jiao" v-show="moneyid==is">
							</view>
						</view>
						<view class="padding-top-sm radius padding-bottom-sm shadow-blur bg-white"  :class="moneyid==is?'curs':''" v-else>
							<view class="bg-white" v-if="parseInt(it.mianzhi)==0">
								<text class="text-bold">自定义面值</text>
							</view>
							<view class="bg-white" v-else>
								<text class="text-bold">{{it.mianzhi}}</text>
							</view>
							<view class="text-center margin-top-xs text-xs padding-xs" v-if="kazong.mode==0">
								<text class="text-price" v-show="parseInt(it.mianzhi)>0">{{(parseFloat(it.mianzhi)*parseFloat(it.feilv)).toFixed(2)}}</text>
								<text class="text-orange color-E2E2FA" :class="parseInt(it.mianzhi)>0?'margin-left-sm':''">{{parseFloat(it.feilv*100).toFixed(2)}}折</text>
							</view>
							<view class="jiao" v-show="moneyid==is">
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
       
	</view>
</template>

<script>
	import footer from '@/components/footer.vue';
	import kefu from '@/components/kefu.vue';
  import popup from '@/components/popup.vue';
	export default {
		components: {
			'v-footer':footer,
		    'v-kefu':kefu,
        'v-popup': popup
		},
		data() {
			return {
       list1:[],
        // 
        iskami:0,//控制卡号显示不显示，有些不需要显示卡号
        cardId: null, // 假设这是用来控制哪个卡片被选中的状态 
        shouldHandleClick: true, // 这个状态用来控制是否应该处理点击事件
				barHeight:0,
				cardtitle:"核销中心",
				showEdit: true,
				basicsList: [{
					cuIcon: 'radioboxfill',
					name: '提交卡号卡密'
				}, {
					cuIcon: 'radioboxfill',
					name: '等待卡密核销'
				}, {
					cuIcon: 'roundclosefill',
					name: '资金到账成功'
				}],
				errtips:null,
				errstr:"",
				copyerr:"",
				successtips:null,
				kajuan:{},
				kazong:{},
				mianzhi:{},
				basics: 0,
				lizi:null,
				isnumok:0,
				modalName:null,
				cardid:0,
				textareaBValue:"",
				cardno:"",
				cardkey:"",
				cardcode:"",
				moneyid:null,
				errlist:[{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'},{msg:'111'}],
				TabCur: 0,
				tips:"请注意提交面值",
				tabNav:[{title:"单卡提交"},{title:"批量提交"}],
				snum:0,
				smoney:0.00,
				radio:"",
				navlis:[],
				idtype:0,
				cardlist:[],
				autom:"",
				submit:0,
				loading:false,
				app: this.app,
        userNotes:'',//用户须知
				cardItem: {},
				discount: '',
        isShow: false ,//控制客服弹出层
        currentTheme: '', //背景色
			}
		},
  
		onLoad(ops) {
      this.currentTheme = this.getTheme();
      this.getInitData()
		    this.barHeight=uni.getSystemInfoSync().statusBarHeight
			console.log(this.cardid,"cardid")
			uni.setNavigationBarTitle({
				title:"寄售中心"
			})
		},

    
		onShow() {
       this.currentTheme = this.getTheme();
			console.log("uni.getStorageSync('typeid')", uni.getStorageSync('typeid'))
			if (uni.getStorageSync('typeid')) {
				this.yh({
					cid: uni.getStorageSync('cid') || '',
					typeid: uni.getStorageSync('typeid') || '',
				});
			} else {
				uni.request({
					method:"post",
					url: this.app.apiHost+"/card",
					header:{'Authorization':''},
					success:(data)=>{
						console.log('data', data.data.data)
						this.idtype = Object.keys(data.data.data)[0];
						console.log('this.idtype', this.idtype)
						this.yh({
							cid: uni.getStorageSync('cid') || '',
							typeid: this.idtype,
						});
					}
				});
			}
			uni.hideTabBar()
		},
		onHide() {
			uni.setStorageSync('cid', '');
			uni.setStorageSync('typeid', '');
			uni.setStorageSync('a', '');
			this.cardKey = '';
			this.cardcode = '';
		},

    // 计算属性返回css样式
    computed: {
      themeClass() {
        return `theme-${this.currentTheme}`;
      }
    },
		methods: {
      getInitData() {
        var that = this;
        uni.request({
          url: that.app.apiHost + '/init',
          method: 'get',
          header: { Authorization: '' },
          success: (data) => {
          this.userNotes=data.data.data.userNotes
          console.log(888,this.userNotes);
          }
        });
      },
      // 获取本地样式
      getTheme() {
        return uni.getStorageSync('theme') || 'dark';
      },
     // 点击客服
     tokefu() {
       this.isShow = !this.isShow;
     },
			getVal (e) {
				let { type } = e.currentTarget.dataset;
				let { value } = e.detail;
				setTimeout(() => {
					this.$data[type] = value;
				}, 100)
			},
			handlerInput (e) {
				let { value } = e.detail;
				value = parseFloat(value); //将输入值转换成浮点型
				var decimalPart = String(value).split('.')[1]; //提取小数部分
				if (decimalPart) { //如果小数部分超过了两位
					if (decimalPart.length >= 2) {
						this.discount = value.toFixed(2);
						this.$forceUpdate()
					} else {
						this.discount = value
					}
					
				} else {
					this.discount = value
				}
			},
			handlerConfirm () {
				let { cardItem, discount } = this.$data;
				let min = cardItem.pricemin*100, max = cardItem.pricemax*100
				if (discount > max) {
					uni.showToast({
						icon: 'none',
						title: '不能超出折扣范围'
					})
					this.discount = this.mianzhi.feilv*100
					return
				} 
				if (discount < min) {
					uni.showToast({
						icon: 'none',
						title: '不能低于折扣范围'
					})
					this.$nextTick(() => {
						this.discount = this.mianzhi.feilv*100
					});
					return
				} 
				this.showEdit = false
				this.mianzhi.feilv = this.discount/100;
			},
			backHome () {
				this.cardKey = '';
				this.cardcode = '';
				uni.removeStorageSync('cid');
				uni.removeStorageSync('typeid');
				uni.navigateBack()
			},
			yh(ops){
        console.log('传递的参数',ops);
				var that=this
				uni.request({
						method:"post",
						url: that.app.apiHost+"/index",
						header:{'Authorization':''},
						success:(data)=>{
							console.log(data.data.code);
							if(data.data.code==0){
								let da=data.data.data
								that.navlis=da.navlist
								console.log(that.navlis,"2222")
								if(ops.typeid!=null && ops.typeid!=undefined){
                  console.log('跳转', 79877998798);
									this.idtype=ops.typeid
								}else{
									this.idtype=this.navlis[0].cid
									this.kajuan=this.navlis[0]
                  console.log('this.kajuan',this.navlis[0]);
									this.modalName=null
									this.cardid=0
									this.mianzhi=[]
									this.moneyid=null
								}
                //循环idtype有没有等于navlis[i].cid
								let is=this.shenav(this.idtype)
                console.log('循环匹配的cid',this.navlis);
								this.kajuan=this.navlis[is]
								if(ops.cid!=null && ops.cid!=undefined)this.cardid=ops.cid
								this.getDatas();
							}
						},
						fail(e) {
						}
				})
			},
			copyErrStr(){
				var that=this
				uni.setClipboardData({
					data:that.copyerr,//要被复制的内容
					success:()=>{//复制成功的回调函数
					  uni.showToast({
					  	title:'复制成功',
						position: 'bottom',
						icon:'none'
					  })
					},
					fail(e) {
						console.log(e)
						uni.showToast({
							title:'复制失败!',
							position: 'bottom',
							icon:'error'
						})
					}
				})
			},
			RadioChange:function(e) {
				console.log(e)
				// #ifndef H5
				this.radio=e[0]
				// #endif
				// #ifdef H5
				// this.radio=e.detail.value[0]
				// console.log(e.detail.value,this.radio);
        this.radio=e[0]
        console.log(e[0]);
				// #endif
			},
			goorder(url){
				uni.switchTab({
					url:url
				})
			},
			hideModal(e) {
				this.modalName = null
			},
			gourl(id){
				uni.navigateTo({
					url:"agree?id="+id
				})
			},
			showModal(e) {
        console.log(88899999,e);
				this.modalName = e.currentTarget.dataset.target
				if(this.modalName=='kazong'){
					this.autom=""
					this.mianzhi={}
					this.moneyid=null
				}
			},
			arrange(){
				let cardtype=this.kazong.typeid,cardprice=this.mianzhi.mianzhi;
				if(cardtype==0 || cardtype=="" || cardtype==undefined){
					this.app.showMsg("请选择卡种")
					return;
				}
				if(cardprice==0 || cardprice=="" || cardprice==undefined){
					this.app.showMsg("请选择面值")
					return;
				}
				if(this.textareaBValue==null || this.textareaBValue=="" || this.textareaBValue==undefined){
					this.app.showMsg("请输入卡号和卡密")
					return;
				}
				let cards=this.textareaBValue
				var that=this;
				uni.request({
					url: that.app.apiHost+"/mach",
					method:'POST',
					header:{'Authorization':'bearer '+that.app.getAuthCode()},
					data:{type:that.kazong.typeid,card:cards},
					success:(data)=>{
						if(data.data.code==-1){
							that.app.showMsg('请登陆后再操作!','../login/login');
						}
						if(data.data.code==1){
							that.app.showMsg(data.data.msg);
						}
						if(data.data.code==0){
							let datas=data.data.msg
							that.textareaBValue=datas
						}else if(data.data.code==3){
							let str=""
							data.data.msg.forEach(function(i,a){
								str=str+i+"\n"
							})
							that.snum=data.data.ok
							that.smoney=parseInt(data.data.ok)*parseInt(that.mianzhi.mianzhi)
							console.log(str,"??")
							that.textareaBValue=str
						}
					},
					fail(a) {
						uni.showToast({
							title:"链接失败",
							position: 'bottom',
							icon:"error"
						})
					}
				})
			},
			textareaBInput(e) {
				this.textareaBValue = e.detail.value
			},
			tabnavSelect(e){
				console.log('e',e)
				this.cardkey=null
				this.cardno=null
				this.textareaBValue=null
				this.TabCur=e.index;
			},
			
			secmoney(e){
				this.moneyid=e.currentTarget.dataset.id
				this.mianzhi=this.kazong.mianzhi[this.moneyid]
				console.log(this.mianzhi)
				// this.discount = this.mianzhi.feilv*100
				if(this.mianzhi.type==1){
					this.modalName="automoney"
				}else{
					this.modalName=null
				}
			},
			automoney(){
				this.modalName=null
				this.kazong.mianzhi[this.moneyid].mianzhi=this.autom
				this.mianzhi.mianzhi=this.autom
			},
			sectype(e){
				this.idtype=this.navlis[e.currentTarget.dataset.id].cid
				this.kajuan=this.navlis[e.currentTarget.dataset.id]
				this.modalName=null
				this.cardtitle="核销中心"
				this.cardid=0
				this.mianzhi=[]
				this.moneyid=null
				this.getDatas();
			},
			secka(e){
                if(e.isjiaji){
                    uni.showToast({
                        title:'维护中'
                    })
                    return 
                }
				console.log('eee', e)
				this.cardid=e.currentTarget.dataset.id
        this.iskami=e.currentTarget.dataset.item.iskami
				this.cardItem=e.currentTarget.dataset.item
				this.modalName=null
				this.kazong=this.cardlist[e.currentTarget.dataset.sid]
				this.cardtitle="寄售中心-"+this.kazong.title
				uni.setNavigationBarTitle({
					title:this.cardtitle
				})
				this.tips=this.kazong.tips
				this.lizi=this.kazong.lizi
			},
			getDatas(){
				var that=this;
				uni.request({
					url: that.app.apiHost+"/getCardLists",
					method:'POST',
					header:{'Authorization':'bearer '+that.app.getAuthCode()},
					data:{cid:that.idtype},
					success:(data)=>{
						if(data.data.code==-1){
							that.app.showMsg('请登陆后再操作!','../login/login');
						}
						let datas=data.data.data;
						that.cardlist=datas
            this.list1=data.data.data
            console.log(111111111,this.list1);
            
						for(var i=0;i<datas.length;i++){
							if(datas[i].id==that.cardid){
								that.kazong=datas[i]
								that.cardItem = datas[i]
								that.tips=datas[i].tips
								that.lizi=datas[i].lizi
								that.cardtitle="寄售中心-"+datas[i].title
                that.iskami=datas[i].iskami
								uni.setNavigationBarTitle({
									title:that.cardtitle
								})
							}
						}
					},
					fail(a) {
						uni.showToast({
							title:"链接失败",
							position: 'bottom',
							icon:"error"
						})
					}
				})
			},
			shenav(e){
        console.log('循环',e);
				for(var i=0;i<this.navlis.length;i++){
					if(e>0 && this.navlis[i].cid==e){
						return i;
					}
				}
				return 0;
			},
			gosub(){
				this.submit=1
				this.subcard()
			},
			subcard(){
				if(this.radio!="A"){
					this.app.showMsg("请阅读并同意服务协议和隐私政策")
					return;
				}
				let cardtype=this.kazong.typeid,cardprice=this.mianzhi.mianzhi,type=this.TabCur;
				if(cardtype==0 || cardtype=="" || cardtype==undefined){
					this.app.showMsg("请选择卡种")
					return;
				}
				if(cardprice==0 || cardprice=="" || cardprice==undefined){
					this.app.showMsg("请选择面值")
					return;
				}
				
				let parms={}
				if(type==0){
					if((this.cardno==null || this.cardno=="" || this.cardno==undefined) && this.kazong.iskami==0){
						this.app.showMsg("请输入卡号")
						return;
					}
					if(this.cardkey==null || this.cardkey=="" || this.cardkey==undefined){
						this.app.showMsg("请输入卡密")
						return;
					}
					 parms = {
						cardtype:cardtype,
						cardprice:cardprice,
						type:type,
						cardno:[this.cardno],
						cardpsw:[this.cardkey]
					    }
						if(this.kazong.isyzm>0){
							if(this.cardcode==null || this.cardcode=="" || this.cardcode==undefined){
								this.app.showMsg("请输入验证码或CVV2码")
								return;
							}
							parms.cardcode=[this.cardcode]
						}
				}else{
					if(this.textareaBValue==null || this.textareaBValue=="" || this.textareaBValue==undefined){
						this.app.showMsg("请输入卡号和卡密")
						return;
					}
					 parms = {
						cardtype:cardtype,
						cardprice:cardprice,
						type:type,
						cardlist:this.textareaBValue,
						submit:this.submit
					    }
				}
				if (this.cardItem.isjiaji) parms.feilv = this.mianzhi.feilv
				uni.showLoading({
					mask:true
				})
				console.log(parms)
				var that=this;
				uni.request({
					url: that.app.apiHost+"/tocard",
					method:'POST',
					header:{'Authorization':'bearer '+that.app.getAuthCode()},
					data:parms,
					success:(data)=>{
						uni.hideLoading()
						if(data.data.code == 40000){
							return that.app.showMsg('请先进行实名认证!','/pages/userinfo/authentication');
						}
						if(data.data.code == 40003){
							return that.app.showMsg('实名认证审核中!');
						}
						if(data.data.code == 40005){
							return that.app.showMsg('请先完成电子签!','/pages/my/sign');
						}
						if(data.data.code==-1){
							that.app.showMsg('请登陆后再操作!','../login/login');
						}
						if(data.data.code==1){
							that.successtips=data.data.msg
							that.app.showMsg(data.data.msg);
						}else if(data.data.code==2){
							that.errtips=data.data.msg
							that.modalName='errtips'
							that.isnumok=data.data.isnum
							that.errstr=data.data.list
							that.errstr.forEach(function(item,i){
								that.copyerr += item.card+" --"+item.msg+'\n'
							})
						}else if(data.data.code==0){
							that.textareaBValue=""
							that.successtips=data.data.msg
							uni.hideLoading()
							that.modalName='success'
						}
					},
					fail(a) {
						uni.showToast({
							title:"链接失败",
							position: 'bottom',
							icon:"error"
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
  /* 定义主题样式 */
  .theme-dark {
    background-color: #151518;
     // color: #fff !important;
     color: #fcecc9 !important;
  }
  
  .theme-light {
    background-color: #fff;
    color: #000;
  }
	/deep/.u-navbar__content__title {
		color: #fff !important;
	}
	/deep/.u-tabs__wrapper__nav__item {
		color: #7B7B8C;
	}
	/deep/.u-tabs {
		position: relative;
		left: -28rpx !important;
	}
	/deep/.bian textarea {
		font-size: 24rpx !important;
	}
	.input-item {
		padding: 24rpx 0rpx;
		border-bottom: 2rpx solid #2E2E41;
		.text-grey {
			// color: #F0E5D6;
		}
	}
	.input-item-box {
		.title {
			width: 80rpx;
		}
		input {
			height: 64rpx;
			// background: #1D1D29;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			opacity: 1;
			// border: 2rpx solid #2E2E41;
			margin-left: 18rpx;
			padding-left: 14rpx;
			// color: #EBCC9D;
		}
	}
	.placeholder-class {
		font-size: 26rpx;
		color: #4C4C66;
	}
	.rule-box {
		padding: 40rpx 30rpx;
		.title {
			font-size: 28rpx;
			color: #F0E5D6;
			padding-left: 10rpx;
		}
		.title::before {
			content: "";
			display: inline-block;
			width: 8rpx;
			height: 32rpx;
			background: linear-gradient(180deg, #FD9D55 0%, #F57843 100%);
			border-radius: 40rpx 40rpx 40rpx 40rpx;
			opacity: 1;
			margin-right: 10rpx;
		}
	}
	.btn-arrange {
		width: 160rpx;
		height: 64rpx;
		background: #ECB676;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		opacity: 1;
	}
 page{
	 background-color: #f1f1f1;
	 
 }
	.screen-swiper{
		width: 98%;
		margin: 10rpx auto;
	}
	.bian{
		width: 100%;
		height: 350rpx;
		// background: #232331;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		opacity: 1;
		// border: 2rpx solid #2C2C3E;
		// color: #EBCC9D;
		font-szie: 26rpx;
	}
	textarea {
		font-szie: 26rpx !important;
	}
	.bianb{
		border:1px solid #F0AD4E
	}
	.hengxian{
		width: 100%;
		background-color: #c5c5c5;
		height: 10px;
	}
	.tops{
		background-color: #FFFFFF;
		margin-left: 0;
		margin-right: 0;
	}
	.navmoney{
		    border: #39b54a 1px solid;
		    background-image: linear-gradient(45deg, #ddd, #d9d9d9);
	}
	.middles{
		margin-left: 0;
		margin-right: 0;
		background-color: #FFFFFF;
	}
	.nav {
		padding: rpx 0 30rpx 0;
		border-bottom: 2rpx solid #2E2E41;
		.active::after {
			content: '';
			width: 60rpx;
			height: 4rpx;
			background: #F0E5D6;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			opacity: 1;
			position: absolute;
			bottom: -30rpx;
			left: 50%;
			transform: translate(-50%, 0);
		}
	}
	.nav {
		.tab-item{
			width: 112rpx;
			margin-right: 68rpx;
			color: #fff;
			position: relative;
		}
		.active {
			width: 112rpx;
			margin-right: 68rpx;
			position: relative;
		}
	}
	.foots{
		width: 100%;
    /* #ifdef MP-WEIXIN */
    position: fixed;
    bottom: 0;
    /* #endif */
		padding-bottom: calc(constant(safe-area-inset-bottom));
		padding-bottom: calc(env(safe-area-inset-bottom));
		// background-color: #32364C;
	}
	.bg-gradual-purple {
	    width: 500rpx;
	    height: 80rpx;
	    background: linear-gradient(1deg, #F6C478 0%, #F8DB9D 100%);
	    border-radius: 200rpx 200rpx 200rpx 200rpx;
	    opacity: 1;
		color: #333;
		margin: 4rpx auto;
		margin-bottom: 26rpx;
	}
	.action {
		padding-right: 6rpx;
	}
	.action image{
		width: 50rpx;
		height: 50rpx;
		margin-right: 22rpx;
		vertical-align: middle;
	}
	.curs{
		border: #39b54a 1px solid;
		overflow: hidden;
	}
	.curs .jiao{
		width: 0px;
		height: 0px;
		border-bottom: 40rpx solid #39b54a;
		border-left: 40rpx solid transparent;
		position: absolute;
		bottom: 0px;
		right: 0;
	}
	.curs::after{
		font-family: "cuIcon";
		font-size: inherit;
		font-style: normal;
		content: "\e645";
		position: absolute;
		bottom: -2px;
		right: -1px;
		color:#FFF;
	}
	.btnsy{
		
	}
	.btnsy input{
		width: 80%;
		border: 1px solid #c1c1c1;
		margin: 5px auto;
		margin-top: 20px;
		height: 70rpx;
		border-radius: 70rpx;
		font-size:14px ;
	}
	
.weihu{
  pointer-events: none; /* 阻止所有鼠标事件 */
}
	

</style>
